//以下为修改jQuery Validation插件兼容Bootstrap的方法，没有直接写在插件中是为了便于插件升级
$.validator.setDefaults({
    highlight: function (element) {
        $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
    },
    success: function (element) {
        element.closest('.form-group').removeClass('has-error').addClass('has-success');
    },
    errorElement: "span",
    errorPlacement: function (error, element) {
        if (element.is(":radio") || element.is(":checkbox")) {
            error.appendTo(element.parent().parent().parent());
        } else {
            error.appendTo(element.parent());
        }
    },
    errorClass: "help-block m-b-none",
    validClass: "help-block m-b-none"
});

//以下为官方示例
$().ready(function () {

    // validate signup form on keyup and submit
    var icon = "<i class='fa fa-times-circle'></i> ";
    $("#meetForm").validate({
        rules: {
            meetDuring: {
                required: true,
                range:[1,500]
            },


            meetTheme: {
                required: true,
                rangelength:[2,40]
            }
        },
        messages: {
            meetDuring: {
                required: icon + "请输入会议时长",
                range: icon + "会议时长只能在1-500之间，单位分钟"
            },


            meetTheme: {
                required: icon + "请输入会议主题",
                rangelength: icon + "会议主题需在2-40个字内"
            }
        }
    });
});
